﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class RecipeTypeOperate : IRecipeTypeOperate
    {
        private HcDbContext _db { get; set; }
        public RecipeTypeOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<RecipeType> GetAllRecipeTypeList()
        {

            return _db.RecipeTypes.ToList();
        }

        public RecipeType GetRecipeTypeById(string id)
        {
            return _db.RecipeTypes.SingleOrDefault(i => i.RecipeTypeId == id);
        }

        public List<RecipeType> GetRecipeTypeByIdList(List<string> ids)
        {
            return _db.RecipeTypes.Where(i => ids.Contains(i.RecipeTypeId)).ToList();
        }

        public void AddRecipeType(RecipeType entity)
        {
            _db.RecipeTypes.Add(entity);
        }

        public void UpdateRecipeType(RecipeType entity)
        {
            _db.RecipeTypes.Update(entity);
        }

        public void DeleteRecipeType(RecipeType entity)
        {
            _db.RecipeTypes.Remove(entity);
        }

        public void BatchDelRecipeType(List<RecipeType> entity)
        {
            _db.RecipeTypes.RemoveRange(entity);

        }
    }
}
